package LocalServerTcp;

import java.net.*;
import java.io.*;
import generalClasses.*;

public class SouthLocalKuponsMultiServer {
    
	public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = null;
        boolean listening = true;
        ProgramData programData = new ProgramData();
        

    	//Creating Main server entity      
        int port=programData.getSouthServerPort();
        String adress=programData.getSouthServerAdress();
        Server southServer= new Server("SouthKuponServer",adress,port,1,1,programData.SOUTH);

        
        try 
        {
            serverSocket = new ServerSocket(port);
        } catch (IOException e) {
            System.err.println("Could not listen on port: "+port+".");
            System.exit(-1);
        }

        while (listening)
        {
        	System.out.println("waiting for connection");
        	new LocalKuponsMultiServerThread(serverSocket.accept(),southServer).start();
        	System.out.println("connection accepted");
        }
        serverSocket.close();
    }
}